package com.local.order.feign;

import com.local.common.util.PageResultUtil;
import com.local.common.util.ResultUtil;
import com.local.order.pojo.Order;
import com.local.order.pojo.OrderItem;
import com.local.order.pojo.OrderListRequestParam;
import com.local.order.pojo.OrdersRequestParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@FeignClient("orderservice")
public interface OrderServiceFeign {

    /**
     * 查询订单列表，支持翻页（后台）
     * @param requestParam
     * @return
     */
    @GetMapping("/order/list")
    @ResponseBody
    public ResultUtil<PageResultUtil<Order>> orderList(@RequestBody OrderListRequestParam requestParam);

    /**
     * 修改（后台）
     * @param order
     * @return
     */
    @PostMapping("/order/update")
    @ResponseBody
    public ResultUtil orderUpdate(@RequestBody Order order);

    /**
     * 批量修改订单状态为：配货完成（后台）
     * @param ids
     * @return
     */
    @PostMapping("/order/checkDone")
    @ResponseBody
    public ResultUtil orderCheckDone(@RequestBody Integer[] ids);

    /**
     * 批量修改订单状态为：出库完成（后台）
     * @param ids
     * @return
     */
    @PostMapping("/order/checkOut")
    @ResponseBody
    public ResultUtil orderCheckOut(@RequestBody Integer[] ids);

    /**
     * 批量修改订单状态为：商家关闭（后台）
     * @param ids
     * @return
     */
    @PostMapping("/order/close")
    @ResponseBody
    public ResultUtil orderClose(@RequestBody Integer[] ids);


    /**
     * 查询订单的所有商品明细（后台）
     * @param orderId
     * @return
     */
    @GetMapping("/order/items/{orderId}")
    @ResponseBody
    public ResultUtil orderItems(@PathVariable("orderId") Integer orderId);


    /**
     * 生成新订单
     * @param order
     * @return
     */
    @PostMapping("/order/saveOrder")
    @ResponseBody
    public ResultUtil<Order> saveOrder(@RequestBody Order order);

    /**
     * 批量添加OrderItems
     * @param orderItemList
     * @return
     */
    @PostMapping("/order/saveOrderItems")
    @ResponseBody
    public ResultUtil<String> saveOrderItems(@RequestBody List<OrderItem> orderItemList);


    /**
     * 获取订单详情
     * @param orderNo
     * @return
     */
    @GetMapping("/order/{orderNo}")
    @ResponseBody
    public ResultUtil<Order> detail(@PathVariable("orderNo") String orderNo);


    /**
     * 前台用户订单列表页，支持翻页
     * @param requestParam
     * @return
     */
    @GetMapping("/order/orders")
    @ResponseBody
    public ResultUtil<PageResultUtil<Order>> orders(@RequestBody OrdersRequestParam requestParam);

}
